import React from 'react';

import {Button, Input, Select, Popconfirm} from 'antd';
import ObjectList from '../../components/ObjectList';

import router from '../../../utils/routerDecorator';
import {get, post} from '../../../logic/api';

export default class Del extends React.Component {

  state = {
  }

  async doDel(){
    var id = this.props.record.id;
    var ret = await post('/admin/custom/delete/' + this.props.record.type + '/' + id);

    if (ret.ok){
      alert("删除成功");
      this.props.reload(); 
    }else{
      alert("删除失败，该类别下不是空");
    }
  }

  render(){
    return <Popconfirm title = "确定删除？" onConfirm = {async ()=>{await this.doDel()}}> 
      <Button type = "primary">
        删除
      </Button>
    </Popconfirm>
  }
}